<template>
  <div>
    <el-table :data="bannerList" style="width: 100%">
      <el-table-column prop="id" label="编号" width="180"> </el-table-column>
      <el-table-column prop="title" label="轮播图标题" width="180"> </el-table-column>
      <el-table-column label="图片" width="180"> 
          <template slot-scope="scope">
          <div>
            <!-- <span>{{scope.row.img}}</span> -->
            <img :src="$pre + scope.row.img" alt="" />
          </div>
        </template>
      </el-table-column>
 <el-table-column label="状态">
        <template slot-scope="scope">
          <div>
            <el-button type="primary" v-if="scope.row.status == 1"
              >启 用</el-button
            >
            <el-button type="success" v-else>禁 用</el-button>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <div>
            <el-button type="info" @click="edit(scope.row.id)">编 辑</el-button>
             <v-del @del="del(scope.row.id)"></v-del>
          </div>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
import { mapGetters, mapActions } from "vuex";
import { bannerDel } from "../../../request/api";
import { successAlert, warningAlert } from "../../../utils/alert";
export default {
  props: [],
  components: {},
  data() {
    return {
    };
  },
  computed: {
    ...mapGetters({
         bannerList:"banner/list"
    }),
  },
  methods: {
    ...mapActions({
         asyncBannerList:"banner/asyncList",
    }),
    edit(id){
   this.$emit("edit",id)
    },
    del(id){
    bannerDel({id:id}).then(res=>{
        if(res.data.code ==200){
        successAlert(res.data.msg)
        this.asyncBannerList()
        }else{
        warningAlert(res.data.msg) 
        }
    })
    }
  },
  mounted() {
      this.asyncBannerList()
  },
};
</script>
<style scoped>
img{
    width: 100px;
    height: 100px;
}
</style>